﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Registro.Compras.Api.Models;
using Registro.Compras.Data.Business;

using System.Threading.Tasks;
using System.Web.Http.Description;
using Registro.Compras.Data.Entities;
using System.Web.Http.Cors;

namespace Registro.Compras.Api.Controllers
{
    [EnableCors(origins: "*", headers: "*", methods: "*")]
    public class ElementoController : ApiController
    {
        // GET api/Elemento/
        public IEnumerable<ElementoModel> Get()
        {
            return ElementoBusiness.GetListByFilter("").Select(t => new ElementoModel
            {
                Id = t.Id,
                Descripcion = t.Descripcion,
            });
        }

        // GET api/Elemento/5
        //[ResponseType(typeof(ElementoModel))]
        public ElementoModel Get(int id)
        {
            Elemento t = ElementoBusiness.GetById(id);
            return new ElementoModel
            {
                Id = t.Id,
                Descripcion = t.Descripcion,
            };
        }
    }
}